﻿package mortal.game.view.godLuckGift.item
{
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class GodLuckGiftIcon extends ActionBaseIcon
    {
        protected var _leftTime:SecTimerView;
        public var leftSecond:int = -1;
        private static var _instance:GodLuckGiftIcon;

        public function GodLuckGiftIcon()
        {
            super(ResFileConst.GodLuckGiftIcon);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.name = "GodLuckGiftIcon";
            this._leftTime = UIFactory.secTimeView("mm:ss", 0, 50, 48, 20, this, GlobalStyle.textFormatHong.center());
            this._leftTime.timeOutHandler = this.timeCompl;
            this._leftTime.visible = false;
            return;
        }// end function

        override protected function timeOutCaller() : void
        {
            this.setLeftTimeAndState(0, 1);
            return;
        }// end function

        private function timeCompl() : void
        {
            this._leftTime.stop();
            this._leftTime.visible = false;
            return;
        }// end function

        public function get sectimerView() : SecTimerView
        {
            return this._leftTime;
        }// end function

        public function updateOpenDt(param1:Date, param2:int) : void
        {
            _state = param2;
            var _loc_3:* = (param1.time - ClockManager.instance.nowDate.time) / 1000;
            this.leftSecond = _loc_3;
            this.setLeftTimeAndState(_loc_3, param2);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this.name = "";
            this._leftTime.dispose(param1);
            this._leftTime = null;
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            this.stopEffect();
            Dispatcher.dispatchEvent(new DataEvent(EventName.GodLuckGiftOpenModule));
            return;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

        public static function get instance() : GodLuckGiftIcon
        {
            if (!_instance)
            {
                _instance = new GodLuckGiftIcon;
            }
            return _instance;
        }// end function

    }
}
